]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
GTKNotificationDaemon: Use ShellApp methods to activate apps
authorJulian Sparber <julian@sparber.net>
Thu, 15 Feb 2024 16:41:29 +0000 (17:41 +0100)
committerJulian Sparber <julian@sparber.net>
Wed, 28 Feb 2024 10:35:38 +0000 (11:35 +0100)
`ShellApp` gained the ability to activated actions and it sets the correct
platform data. Therefore drop the current implementation in favor for it.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7409
Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5239
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3198>

js/ui/notificationDaemon.js

index d6aa3811c4c8275c0fa04d2b62f6d34ed623bf6b..4aceb2468504822748978befbc194d7cbe1b9bd9 100644 (file)
@@ -472,28 +472,12 @@ class GtkNotificationDaemonNotification extends MessageTray.Notification {
     }
 });
 
-const FdoApplicationIface = loadInterfaceXML('org.freedesktop.Application');
-const FdoApplicationProxy = Gio.DBusProxy.makeProxyWrapper(FdoApplicationIface);
-
-function objectPathFromAppId(appId) {
-    return `/${appId.replace(/\./g, '/').replace(/-/g, '_')}`;
-}
-
-/**
- * @returns {{ 'desktop-startup-id': string }}
- */
-function getPlatformData() {
-    let startupId = GLib.Variant.new('s', `_TIME${global.get_current_time()}`);
-    return {'desktop-startup-id': startupId};
-}
-
 function InvalidAppError() {}
 
 export const GtkNotificationDaemonAppSource = GObject.registerClass(
 class GtkNotificationDaemonAppSource extends MessageTray.Source {
     constructor(appId) {
-        const objectPath = objectPathFromAppId(appId);
-        if (!GLib.Variant.is_object_path(objectPath))
+        if (!Gio.Application.id_is_valid(appId))
             throw new InvalidAppError();
 
         const app = Shell.AppSystem.get_default().lookup_app(`${appId}.desktop`);
@@ -508,47 +492,26 @@ class GtkNotificationDaemonAppSource extends MessageTray.Source {
 
         this._appId = appId;
         this._app = app;
-        this._objectPath = objectPath;
 
         this._notifications = {};
         this._notificationPending = false;
     }
 
-    _createApp() {
-        return new Promise((resolve, reject) => {
-            new FdoApplicationProxy(Gio.DBus.session,
-                this._appId, this._objectPath, (proxy, err) => {
-                    if (err)
-                        reject(err);
-                    else
-                        resolve(proxy);
-                });
-        });
-    }
-
     _createNotification(params) {
         return new GtkNotificationDaemonNotification(this, params);
     }
 
-    async activateAction(actionId, target) {
-        try {
-            const app = await this._createApp();
-            const params = target ? [target] : [];
-            app.ActivateActionAsync(actionId, params, getPlatformData());
-        } catch (error) {
-            logError(error, 'Failed to activate app proxy');
-        }
+    activateAction(actionId, target) {
+        const params = target ? GLib.Variant.new('av', [target]) : null;
+        this._app.activate_action(actionId, params, 0, -1, null).catch(error => {
+            logError(error, `Failed to activate action for ${this._appId}`);
+        });
         Main.overview.hide();
         Main.panel.closeCalendar();
     }
 
-    async open() {
-        try {
-            const app = await this._createApp();
-            app.ActivateAsync(getPlatformData());
-        } catch (error) {
-            logError(error, 'Failed to open app proxy');
-        }
+    open() {
+        this._app.activate();
         Main.overview.hide();
         Main.panel.closeCalendar();
     }